//
//  Category.m
//  Bespoke
//
//  Created by Cheng on 12/8/2.
//
//

#import "Category.h"
#import "AccountCategory.h"

@implementation Category
@synthesize AC_Channel;
@synthesize delegate;


#pragma mark - UITableViewDelegate

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *ButtonCellIdentifier = @"ButtonCell";
    UITableViewCell *Tablecell = [tableView dequeueReusableCellWithIdentifier:ButtonCellIdentifier];
    
    UIView *bgColorView = [[UIView alloc] init];
    UIColor *UC_skyblue= [UIColor colorWithRed:206.0/255.0 green:235.0/255.0 blue:236.0/255.0 alpha:1.0];
    [bgColorView setBackgroundColor:UC_skyblue];
    
    if (Tablecell == nil) {
        
        Tablecell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ButtonCellIdentifier];
        Tablecell.textLabel.font = [UIFont fontWithName:@"Helvetica" size:15];
        Tablecell.textLabel.textColor = [UIColor darkGrayColor];
        [Tablecell setSelectedBackgroundView:bgColorView];
    }
    
    Tablecell.textLabel.text = [[AC_Channel.Array_Categories objectAtIndex:indexPath.row] NS_CategoryName];
    return Tablecell;
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return AC_Channel.Array_Categories.count; // or self.items.count;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [delegate uiViewTouched_Category:NO ];
    [delegate DidSelected_Category:[[AC_Channel.Array_Categories objectAtIndex:indexPath.row] NS_CategoryName]];
}

#pragma mark - Touches

- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event
{
    if( point.x > 0 && point.x < self.frame.size.width && point.y > 0 && point.y < self.frame.size.height )
    {
        [delegate uiViewTouched_Category:YES ];
        return YES;
    }
    
    [delegate uiViewTouched_Category:NO ];
    return NO;
}

@end
